/* 
 * File:   Linda.h
 * Author: JM
 *
 * Created on 11 maj 2010, 20:21
 */

#ifndef _LINDA_H
#define	_LINDA_H
#include "standardLindaHeaders.h"
#include "LindaExceptions.h"

class Linda {
public:
    Linda(int aQueueId);
    Linda(const Linda& orig);
    virtual ~Linda();

    //void lindaInit(key_t aQueueId);
    /**
     * Read from Linda universe
     */
    std::string read(const std::string, const int aTimeout = -1) throw(LindaReceivingException,
            LindaSendingException, LindaTimeoutException, LindaServerErrorException, LindaMalformedMessageException);

    /**
     * Exclusive read from Linda universe (delete msg)
     */
    std::string input(const std::string, const int aTimeout = -1) throw(LindaReceivingException,
            LindaSendingException, LindaTimeoutException, LindaServerErrorException, LindaMalformedMessageException);

    /**
     * Put msg in Linda universe
     */
    void output(const std::string) throw(LindaSendingException);

private:
    std::string sendToServerAndWaitForAnswer(const int aType, const std::string aMessage, const int aTimeout)
            throw(LindaSendingException, LindaReceivingException, LindaTimeoutException, LindaServerErrorException,
                  LindaMalformedMessageException);

private:
    int iQueueId;
    int iPrivateQueueId;
};

#endif	/* _LINDA_H */

